Python Quick Start
Get OptalCP running in Python in under 5 minutes.
Prerequisites
- Python 3.11 or later
- pip (Python package installer)
Installation
Install the Preview edition (free for evaluation):
pip install git+https://github.com/ScheduleOpt/optalcp-py-bin-preview@latest
tip
For academic research or production use, see Editions for other options.
Your First Scheduling Model
Create a file test_optalcp.py:
import optalcp as cp
model = cp.Model()
x = model.interval_var(length=10, name="x")
y = model.interval_var(length=10, name="y")
model.end_before_start(x, y) # y starts after x ends
model.minimize(y.end())
result = model.solve()
print(f"Objective: {result.objective}")
Run it:
python test_optalcp.py
You'll see the solver log first, then the output from your program:
──────────────────────────────────────────────────────────────────────────────── ScheduleOpt OptalCP Version 2025.12.1 (Linux) CPU: AMD Ryzen 9 5950X (16 physical cores) ──────────────────────────────────────────────────────────────────────────────── Input parse time: 00:00 nbWorkers = 16 (auto: 16 physical cores) preset = Default (auto: < 100,000 variables) noOverlapPropagationLevel = 4 (preset: Default) cumulPropagationLevel = 3 (preset: Default) Workers 0-7: searchType = LNS (preset: Default) Workers 8-13: searchType = FDS (preset: Default) Workers 14-15: searchType = FDSDual (preset: Default) Input: 0 integer variables, 2 interval variables, 1 constraints, 9.38kB 00:00 Presolving.. Presolved: 0 integer variables, 2 interval variables, 1 constraints, 9.37kB 00:00 Presolve complete, starting search. ──────────────────────────────────────────────────────────────────────────────── 00:00 ↑ Lower bound 20 Worker 8 00:00 ↓ Solution 20 Worker 8: FDS 00:00 The current best solution is optimal. ──────────────────────────────────────────────────────────────────────────────── Objective value: 20 (optimal) Lower bound: 20 Solutions: 1 LNS steps: 0 (0.00 per second) Restarts: 0 (0.00 per second) Branches: 156 (8706.41 per second) Fails: 10 (558.10 per second) Total duration: 00:00.02 Memory: 146MB ──────────────────────────────────────────────────────────────────────────────── Objective: 20
Next Steps
- Tutorial — Learn scheduling concepts step-by-step
- Editions — Compare Preview, Academic, and Full editions
- Python API — Complete Python API documentation
See also
- JavaScript Quick Start — Same guide for JavaScript/TypeScript